#include <QtGui>
#include <QtCore/QTextCodec>
#include <QMessageBox>
#include <QTranslator>
#include "gv_setuphomedialog.h"
#include "gv_setupchangepwddiaglog.h"
#include "gv_setuplanguagedialog.h"
#include "gv_setuptimedialog.h"
#include "gv_maintenancehome.h"
#include "gv_maintenancealarmsettingdialog.h"
#include "gv_maintenancezerocalibrate.h"
#include "gv_home.h"
#include "gv_setting.h"

extern GV_Setting *gvsetting;
extern QDialog  *dialog;
GV_MaintenanceZerocalibrateDialog::GV_MaintenanceZerocalibrateDialog(QWidget *parent)
       : QDialog(parent)
{
    setupUi(this);

    QTranslator translator;
    translator.load(gvsetting->GV_GetLanguage(),".");
    qApp->installTranslator(&translator);
    reloadtext();

    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));

    timer = new QTimer;
    connect(timer,SIGNAL(timeout()),this,SLOT(GV_chTime()));
    connect(CancelButton,SIGNAL(clicked()),this,SLOT(home()));
    //connect(AcceptButton,SIGNAL(clicked()),this,SLOT(home()));

    connect(pushButton,SIGNAL(clicked()),this,SLOT(zeroCalibrateWarning()));
    connect(pushButton_2,SIGNAL(clicked()),this,SLOT(zeroCalibrateWarning()));
    connect(pushButton_3,SIGNAL(clicked()),this,SLOT(zeroCalibrateWarning()));
    connect(pushButton_4,SIGNAL(clicked()),this,SLOT(zeroCalibrateWarning()));
    connect(pushButton_5,SIGNAL(clicked()),this,SLOT(zeroCalibrateWarning()));
    connect(pushButton_6,SIGNAL(clicked()),this,SLOT(zeroCalibrateWarning()));
    //connect(TimeanddateButton,SIGNAL(clicked()),this,SLOT(timeanddate()));
    //connect(LanguageselectionButton,SIGNAL(clicked()),this,SLOT(changelanguage()));
    timer->start(1000);
}

void GV_MaintenanceZerocalibrateDialog::reloadtext()
{
    NameHintsLabel->setText(tr("Maintenance"));

    HelpButton->setText(tr("Help"));
    CancelButton->setText(tr("Cancel"));
    CalibrateButton->setText(tr("Calibrate"));

    //SystemTransmittersSetuptabWidget->setTabText(0,tr("Time Past"));
    //SystemTransmittersSetuptabWidget->setTabText(1,tr("Detailed View"));

    //LabelDaysName->setText(tr("Days"));

    //LabelTransmittersAlarmColum->setText(tr("Transmitters"));
    //LabelTransmittersInstalledColum->setText(tr("Time Installed"));

    //LabelTransmittersAlarm1e->setText(tr("1e Alarm"));
    //LabelTransmittersAlarm2e->setText(tr("2e Alarm"));
    //LabelTransmittersAlarm3e->setText(tr("3e Alarm"));
}
void GV_MaintenanceZerocalibrateDialog::GV_chTime()
{
    TimeHintsLabel->setText((QDateTime::currentDateTime().toString("hh:mm:ss")));
    DateHintsLabel->setText((QDateTime::currentDateTime().toString("yyyy-MM-dd")));
}

void GV_MaintenanceZerocalibrateDialog::home()
{
    QDialog *dialog1 = new GV_MaintenanceHomeDialog;
    dialog1->show();
    delete dialog;
    dialog = dialog1;
}

void GV_MaintenanceZerocalibrateDialog::zeroCalibrateWarning()
{
    if (QMessageBox::warning(this, "Maintenance",
                        "Warning All the LPG sensors selected will be calibrated to Zero! Are you sure to continue?",
                        QMessageBox::Yes,
                        QMessageBox::No) == QMessageBox::Yes) {
                    //TODO
                }
}







